<?php 
 $likscale = array ('' => '',
 										'exceptional' => 'exceptional', 
 										'above average' => 'above average', 
 										'average' => 'average', 
 										'below average' => 'below average',
 										'insufficient opportunity to observe' => 'insufficient opportunity to observe'
 									 );
 									 
 $perscale = array('' => '',
 									 'Top 2%' => 'Top 2%',
 									 'Top 10%' => 'Top 10%', 
 									 'Top 25%' => 'Top 25%', 
 									 'Top 50%' => 'Top 50%',
 									 'Not in Top 50%' => 'Not in Top 50%',
 									 'Insufficient Opportunity to Observe' => 'Insufficient Opportunity to Observe'
 									);
 
 $overall = array('' => '',
 									'strongly recommended' => 'strongly recommended', 
 									'recommended' => 'recommended', 
 									'recommended with reservations' => 'recommended with reservations'
 								 );
 
$fullname = $this->data['Application']['firstname'] . ' ' . $this->data['Application']['lastname']; 
 
if (!empty($this->data) 
		&& $this->data['Reference']['complete']) {
	echo '<h3>Recommendation Complete</h3>';
	echo "<h3>Thank you! Your recommendation is complete.</h3>";
	echo '<p> You should receive a confirmation email containing your responses to the evaluation form' .
				' within the next few minutes. If you do not receive this email please contact the graduate secretary' .
				' she can provide you with a copy of your submission for your records</p>';
	$date = explode(' ', $this->data['Reference']['modified']);
	$date = $date[0];
	echo "<h4 style=\"color:blue;\">Your recommendation was successfully submitted on {$date}. If you believe you are seeing this message in error please contact gradsec@psych.uoregon.edu or call +1(541) 346-5060. </h4>";
	return;	
} 

if (empty($this->data)) {
	echo '<h3>Submit a Recommendation </h3>';
	echo '<p> Sorry, The reference you are trying to reach does not exist. If you are receiving this message in error, please contact gradsec@psych.uoregon.edu.</p>';
	echo '</div></div>';
	return;
}

?>
<div id="refContent">
<h3>Submit Recommendation For <?php echo $fullname; ?></h3>

	<p>
		Please submit your recommendation for <?php echo $fullname ?>. 
		Upon completion, your responses to this evaluation will be emailed to you for your records. 
		If you have questions or concerns please contact the graduate secretary at; gradsec@psych.uoregon.edu.
	</p>	
	
	<?php echo $this->Form->create('Reference', array('type' => 'file', 
																										'url' => array(
																											'action' => 'evaluate',
																											$this->data['Reference']['id'],
																											$this->data['Reference']['uid']
																										)
																							)
																	); ?>
	<fieldset><legend>Attach a letter</legend>
	<p> 
		<?php echo $info ?>
	</p>
	
	<div id="refletter_list"> 
		<table cellpadding="0" cellspacing="0">
			<tr class="head"><th>Filename: </th><th>Uploaded on:</th><th>Delete:</th></tr>
			<tr class="odd">
			<?php 
				if (empty($this->data['Reference']['file_name'])) {
							echo '<td colspan="3">No File attached.</td>';
						} else {
							echo "<td>" . $this->Html->link($this->data['Reference']['file_name'], array(
															'controller' => 'References', 
															'action' => 'viewLetter',
															$this->data['Reference']['id'],
															$this->data['Reference']['uid'])) . "</td>";
							$date = explode(' ', $this->data['Reference']['file_date']);
							$date = $date[0];
							echo "<td>{$date}</td>";
			 				echo "<td>" . $this->Html->link('Remove', array(
															'controller' => 'References', 
															'action' => 'deleteLetter',
															$this->data['Reference']['id'],
															$this->data['Reference']['uid'])) . "</td>";}
			?>
			</tr>		
		</table>
	</div>
		<?php echo $this->Form->input('id'); ?>
		<?php echo $this->Form->input('Reference.content', array(
																		'label' => 'Upload Reference Letter', 
																		'type' => 'file')); ?>
		</fieldset>
	<?php echo $this->Form->end('Attach Letter');	?>
	
	<p>
		Under the Federal Law entitled the Family Educational Rights and Privacy Act(FERPA) of 1974 and the University of Oregon Student Record Policy, 
		registered students are given the right to inspect their records, including letters of recommendation. 
		<?php echo '<strong>' . $fullname . ' '; 
					echo ($this->data['Reference']['ferpa_waived'])? 'has waived</strong>':'has not waived</strong>'; 
		?> his/her rights to access this evaluation under FERPA. 
	</p>
	<?php echo $this->Form->create('Reference', array('url' => array(
							'action' => 'evaluate',
							$this->data['Reference']['id'],
							$this->data['Reference']['uid']),
							'onSubmit' => 'return confirm("You will be unable to edit this evaluation once' 
																						. ' you submit it. Are you sure you wish to submit?");')); ?>
	<fieldset>
		<legend>Your Contact Information</legend>
		<?php echo $this->Form->input('id'); ?>
		<?php echo $this->Form->input('application_id', array('type' => 'hidden')); ?>
		<?php echo $this->Form->input('complete', array('type' => 'hidden', 'value' => true)); ?>
		<?php echo $this->Form->input('firstname', array('label' => 'First Name')); ?>
		<?php echo $this->Form->input('lastname', array('label' => 'Last Name')); ?>
		<?php echo $this->Form->input('title', array('label' => 'Position Title')); ?>
		<?php echo $this->Form->input('phone', array('label' => 'Contact Phone')); ?>
	</fieldset>
	<fieldset> 
		<legend>Evaluation of <?php echo $fullname ?></legend>
		<?php echo $this->Form->input('knowledge_length', 
					array('label' => 'How long and in what capacity have you known the applicant? <br />(255 character limit)')); ?>
		<?php echo $this->Form->input('has_grad_prog', array('options' =>  array('0' =>'', '1'=> 'No', '2'=> 'Yes'),
																										'label' => 'Do you have a graduate program?')); ?>
		<?php echo $this->Form->input('would_admit', array('options' =>  array('0' =>'', '1'=> 'No', '2'=> 'Yes'),
																											 'label' => 'If yes, and if the decision were entirely up to you, <br />would you admit the applicant into your program?')); ?>
		<?php echo $this->Form->input('not_admit_info', array('type' => 'textarea', 'label' => 'If no, why not?')); ?>
		<p> Please rate the applicant on the following qualities: </p>
		<?php echo $this->Form->input('intel_ability', array('label' => 'Intellectual ability', 'options' => $likscale)); ?>
		<?php echo $this->Form->input('academic_prep', array('label' => 'Academic preparation', 'options' => $likscale)); ?>
		<?php echo $this->Form->input('maturity', array('label' => 'Maturity/Responsibility', 'options' => $likscale)); ?>
		<?php echo $this->Form->input('interpersonal_skills', array('label' => 'Interpersonal skills', 'options' => $likscale)); ?>
		<?php echo $this->Form->input('oral_comm', array('label' => 'Oral communication skills', 'options' => $likscale)); ?>
		<?php echo $this->Form->input('written_comm', array('label' => 'Written communication skills', 'options' => $likscale)); ?>
		<?php echo $this->Form->input('finishes_tasks', array('label' => 'Ability to complete tasks', 'options' => $likscale)); ?>
		<?php echo $this->Form->input('creative_think', array('label' => 'Creative, integrative thinking', 'options' => $likscale)); ?>
		<?php echo $this->Form->input('independent_work', array('label' => 'Ability to work independently', 'options' => $likscale)); ?>
		<?php echo $this->Form->input('professional_clinic', array('label' => '(Clinical applicants only) Ability to handle clinical issues in a professional manner', 'options' => $likscale)); ?>
		
		<p>Compared to other graduate students, please rate the applicant on the following: </p>
		<?php echo $this->Form->input('motivation', array('label' => 'Motivation', 'options' => $perscale)); ?>
		<?php echo $this->Form->input('originality', array('label' => 'Originality', 'options' => $perscale)); ?>
		<?php echo $this->Form->input('initiative', array('label' => 'Initiative', 'options' => $perscale)); ?>
		<?php echo $this->Form->input('critical_thinking', array('label' => 'Critical thinking', 'options' => $perscale)); ?>
		<?php echo $this->Form->input('emot_stability', array('label' => 'Emotional stability', 'options' => $perscale)); ?>
		<?php echo $this->Form->input('perseverance', array('label' => 'Perseverance', 'options' => $perscale)); ?>
		<?php echo $this->Form->input('overall', array('label' => 'Overall this applicant is', 'options' => $overall)); ?>

	</fieldset>
	<?php echo $this->Form->end('Complete Evaluation') ?>	
</div> <!--end content-->
